package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/16 14:26
 * @description
 */
public class Code404 {
    private int total;

    public int sumOfLeftLeaves(TreeNode root) {
        setTotal(root, false);
        return total;
    }

    private void setTotal(TreeNode node, boolean flag) {
        if (node != null) {
            if (flag && node.left == null && node.right == null) {
                total += node.val;
            }
            setTotal(node.left, true);
            setTotal(node.right, false);
        }
    }
}
